package com.dandelion.manager.system.domain;

import java.io.Serializable;
import java.util.Date;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;

import com.dandelion.commons.domain.BaseDomain;
import com.dandelion.commons.utils.PropertyUtils;

public class User extends BaseDomain implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private static String applicationSalt = PropertyUtils.getValue("shiro.applicationSalt");

	private Long id;

    private String username;

    private String password;

    private String userSalt;

    private String truename;

    private String email;

    private Integer locked;

    private Integer editable;

    private Date preLoginTime;

    private String preLoginIp;

    private Date lastLoginTime;

    private String lastLoginIp;

    private Date lastLogoutTime;

    private Date createTime;

    private Date updateTime;

    private String validateCode;

    private Date outDatetime;
    
    private Auth auth ;
    
    /*******************业务属性*********************/
    //旧密码
    private String oldPassword ;
    //新密码
    private String newPassword ;
    
    
	/**
     * 加密盐
     */
    public void SecureRandomSalt() {
        setUserSalt(new SecureRandomNumberGenerator().nextBytes().toHex());
    }
    
    /**
     * 组合加密盐
     * @return
     */
    public String getCredentialsSalt() {
		return applicationSalt + username + getUserSalt() ;
	}
    
	public String getOldPassword() {
		return oldPassword;
	}

	public void setOldPassword(String oldPassword) {
		this.oldPassword = oldPassword;
	}

	public String getNewPassword() {
		return newPassword;
	}

	public void setNewPassword(String newPassword) {
		this.newPassword = newPassword;
	}

	public Auth getAuth() {
		return auth;
	}

	public void setAuth(Auth auth) {
		this.auth = auth;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUserSalt() {
		return userSalt;
	}

	public void setUserSalt(String userSalt) {
		this.userSalt = userSalt;
	}

	public String getTruename() {
		return truename;
	}

	public void setTruename(String truename) {
		this.truename = truename;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Integer getLocked() {
		return locked;
	}

	public void setLocked(Integer locked) {
		this.locked = locked;
	}

	public Integer getEditable() {
		return editable;
	}

	public void setEditable(Integer editable) {
		this.editable = editable;
	}

	public Date getPreLoginTime() {
		return preLoginTime;
	}

	public void setPreLoginTime(Date preLoginTime) {
		this.preLoginTime = preLoginTime;
	}

	public String getPreLoginIp() {
		return preLoginIp;
	}

	public void setPreLoginIp(String preLoginIp) {
		this.preLoginIp = preLoginIp;
	}

	public Date getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public String getLastLoginIp() {
		return lastLoginIp;
	}

	public void setLastLoginIp(String lastLoginIp) {
		this.lastLoginIp = lastLoginIp;
	}

	public Date getLastLogoutTime() {
		return lastLogoutTime;
	}

	public void setLastLogoutTime(Date lastLogoutTime) {
		this.lastLogoutTime = lastLogoutTime;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String getValidateCode() {
		return validateCode;
	}

	public void setValidateCode(String validateCode) {
		this.validateCode = validateCode;
	}

	public Date getOutDatetime() {
		return outDatetime;
	}

	public void setOutDatetime(Date outDatetime) {
		this.outDatetime = outDatetime;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
}